package com.rdc.example.bean;

import com.rdc.example.constant.ResultConst;

/**
 * @author Wookie
 * @description 统一返回结果封装类
 */
public class Result {
    /**
     * 返回状态码
     */
    private Integer code;

    /**
     * 返回消息
     */
    private String message;

    /**
     * 返回数据
     */
    private Object data;


    public Result() {
    }

    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static Result success(String msg, Object data) {
        return new Result(ResultConst.SUCCESS, msg, data);
    }

    public static Result fail(String msg, Object data) {
        return new Result(ResultConst.FAIL, msg, data);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Result{code = " + code + ", message = " + message + ", data = " + data + "}";
    }

}
